home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / Qpopper / pop_list.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-01  |  2.0 KB  |  65 lines

  1. /*
  2.  * Copyright (c) 1989 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef lint
  8. static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
  9. static char SccsId[] = "@(#)@(#)pop_list.c    2.1  2.1 3/18/91";
  10. #endif not lint
  11.  
  12. #include <stdio.h>
  13. #include <sys/types.h>
  14. #include "popper.h"
  15.  
  16. /* 
  17.  *  list:   List the contents of a POP maildrop
  18.  */
  19.  
  20. int pop_list (p)
  21. POP     *   p;
  22. {
  23.     MsgInfoList         *   mp;         /*  Pointer to message info list */
  24.     register int            i;
  25.     register int            msg_num;
  26.  
  27.     /*  Was a message number provided? */
  28.     if (p->parm_count > 0) {
  29.         msg_num = atoi(p->pop_parm[1]);
  30.  
  31.         /*  Is requested message out of range? */
  32.         if ((msg_num < 1) || (msg_num > p->msg_count))
  33.             return (pop_msg (p,POP_FAILURE,
  34.                 "Message %d does not exist.",msg_num));
  35.  
  36.         /*  Get a pointer to the message in the message list */
  37.         mp = &p->mlp[msg_num-1];
  38.  
  39.         /*  Is the message already flagged for deletion? */
  40.         if (mp->del_flag)
  41.             return (pop_msg (p,POP_FAILURE,
  42.                 "Message %d has been deleted.",msg_num));
  43.  
  44.         /*  Display message information */
  45.         return (pop_msg(p,POP_SUCCESS,"%u %u",msg_num,mp->length));
  46.     }
  47.     
  48.     /*  Display the entire list of messages */
  49.     pop_msg(p,POP_SUCCESS,
  50.         "%u messages (%u octets)",
  51.             p->msg_count-p->msgs_deleted,p->drop_size-p->bytes_deleted);
  52.  
  53.     /*  Loop through the message information list.  Skip deleted messages */
  54.     for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) {
  55.         if (!mp->del_flag) 
  56.             (void)fprintf(p->output,"%u %u\r\n",mp->number,mp->length);
  57.     }
  58.  
  59.     /*  "." signals the end of a multi-line transmission */
  60.     (void)fprintf(p->output,".\r\n");
  61.     (void)fflush(p->output);
  62.  
  63.     return(POP_SUCCESS);
  64. }
  65.